package com.ptit.giaothong;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.database.Cursor;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

import com.ptit.giaothong.database.DatabaseHelper;

public class GlobalData {
	public static List<ItemScores> getHeightScores() {
		List<ItemScores> listScores = null;
		Cursor c = DelayActivity.myDbHelper.query(DatabaseHelper.TB_QUESTION,
				null, null, null, null, null, null);

		String sql = "select * from " + DatabaseHelper.TB_DC;
		c = DelayActivity.myDbHelper.rawQuery(sql);
		int nID = 0;
		listScores = new ArrayList<ItemScores>();

		if (c.moveToFirst()) {
			do {
				ItemScores item = new ItemScores();
				item.setStt(nID);
				item.setName(c.getString(1));
				item.setScores(c.getLong(2));
				item.setDatetime(c.getString(3));
				listScores.add(item);
				nID++;
			} while (c.moveToNext());
		}
		return listScores;

	}

	public static void setAdapterSpinner(Activity activity, Spinner spinner,
			String[] showString) {
		ArrayAdapter<String> adapterMenhgia = new ArrayAdapter<String>(
				activity, R.layout.my_spinner_textview, showString);
		adapterMenhgia
				.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		spinner.setAdapter(adapterMenhgia);

	}
}
